package com.alex.config.useprototype;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

public class ServiceB implements ApplicationContextAware {

    private ApplicationContext context;

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.context = applicationContext;
    }

    public void sayServiceA() {
        System.out.println(getServiceA());
    }

    private ServiceA getServiceA() {
        return this.context.getBean("serviceA", ServiceA.class);
    }
}
